package com.webex.ta.hydra.core;

import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
 * Created by Cisco WebEx.
 * User: vegaz
 * Date: 2010-8-18
 * Time: 9:53:52
 */
@XStreamAlias("ParamDescriptor")
public class ParamDescriptor {

    private String name, description;

    private ParamType type;

    private boolean optional;

    private String[] candidates;

    public ParamDescriptor(String description) {
        this("", ParamType.TEXT, description, false, null);
    }

    public ParamDescriptor(String description, boolean optional) {
        this("", ParamType.TEXT, description, optional, null);
    }

    public ParamDescriptor(ParamType type, String description, boolean optional, String[] candidates) {
        this("", type, description, optional, candidates);
    }

    public ParamDescriptor(String name, ParamType type, String description, boolean optional, String[] candidates) {
        this.name = name;
        this.type = type;
        this.description = description;
        this.optional = optional;
        this.candidates = candidates;
    }



    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public String[] acceptableValues() {
        return new String[0];
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setType(ParamType type) {
        this.type = type;
    }

    public ParamType getType() {
        return type;
    }

    public void setOptional(boolean v) {
        optional = v;
    }

    public boolean isOptional() {
        return optional;
    }

    public void setCandidates(String[] candidates) {
        this.candidates = candidates;
    }

    public String[] getCandidates() {
        return candidates;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("DefaultParamDescriptor[name=").
                append(name).
                append(", type=").
                append(type).
                append(", description=").
                append(description).
                append(", accpetableValues=[");
        for (String v : acceptableValues()) {
            sb.append(v);
            sb.append(",");
        }
        sb.append("]");
        sb.append("]");

        return sb.toString();
    }
}
